import * as types from '../actionTypes/todos'

// 删除任务action
export const delTodo = id => {
  return {
    type: types.DEL_TODO,
    payload: id
  }
}

// 切换任务状态
export const toggleDone = (id, checked) => {
  return {
    type: types.TOGGLE_DONE,
    payload: {
      id,
      done: checked
    }
  }
}

// 添加任务
export const addTodo = (text) => {
  return {
    type: types.ADD_TODO,
    payload: text
  }
}

// 切换全选
export const toggleAll = (checked) => {
  return {
    type: types.TOGGLE_ALL,
    payload: checked
  }
}

// 清空已完成
export const clearDone = () => {
  return { type: types.CLEAR_DONE }
}

// 修改任务
export const updateTodo = (id, todoName) => {
  return {
    type: types.UPDATE_TODO,
    payload: { id, text: todoName }
  }
}